
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>2、Runtime - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>2、Runtime - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">在Java中，`java.lang.Runtime`类的核心作用是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Runtime类的核心作用是代表当前Java应用程序的运行时环境，通过它，开发者可以获取和控制JVM的运行时信息，并执行系统级的操作。</div>
          </div>
          <div class="card-source">来源: 1. Runtime 类简介</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">如何获取`Runtime`类的实例？这种方式体现了哪种设计模式？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">通过静态方法`Runtime.getRuntime()`来获取`Runtime`类的实例。这种实现方式表明`Runtime`类是一个单例类，采用了单例设计模式。</div>
          </div>
          <div class="card-source">来源: 2.1 获取 Runtime 实例</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">`Runtime`类提供了哪些方法来获取关于JVM内存状况的信息？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">提供了三个主要方法：`totalMemory()`用于获取JVM的总内存量，`freeMemory()`用于获取JVM的空闲内存量，以及`maxMemory()`用于获取JVM的最大可用内存量。</div>
          </div>
          <div class="card-source">来源: 2.2 获取系统信息</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">如何使用`Runtime`类执行一个外部系统命令（例如 `ls -l`），并且该方法会返回什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">可以通过调用`exec(String command)`方法来执行外部系统命令，例如`runtime.exec("ls -l")`。该方法会返回一个`Process`对象。</div>
          </div>
          <div class="card-source">来源: 2.3 执行系统命令</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">`Runtime.exit(int status)`方法的功能是什么？参数`status`的常规约定是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">该方法用于退出当前的Java虚拟机（JVM）。按照常规约定，一个非零的状态码（status）表示异常退出，而零状态码表示正常退出。</div>
          </div>
          <div class="card-source">来源: 2.4 关闭 JVM</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">应用</div>
          <div class="card-question">根据文档，`Runtime`类的主要应用场景有哪些？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">应用</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">主要应用场景包括三个方面：1. 执行系统命令，如调用外部程序；2. 管理系统资源，如监控内存和处理器使用情况；3. 控制JVM行为，如关闭JVM。</div>
          </div>
          <div class="card-source">来源: 3. Runtime 类的应用场景</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">安全</div>
          <div class="card-question">在使用`Runtime`类执行系统命令时，需要特别注意哪个安全问题？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">安全</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">需要特别注意命令注入（command injection）等安全漏洞，尤其是在处理用户输入来构造命令时必须非常谨慎。</div>
          </div>
          <div class="card-source">来源: 4. 安全注意事项</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">`Runtime`类中的`availableProcessors()`方法的作用是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">该方法用于获取Java虚拟机（JVM）可用的处理器数量。</div>
          </div>
          <div class="card-source">来源: 2.2 获取系统信息</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">总结</div>
          <div class="card-question">为什么说深入了解`Runtime`类有助于提高Java应用的灵活性和可维护性？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">总结</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">因为通过`Runtime`类，开发者可以更好地利用工具来管理系统资源、执行系统命令，从而增强应用与操作系统环境的交互能力，使其更加灵活和易于维护。</div>
          </div>
          <div class="card-source">来源: 5. 总结</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
